package cn.tedu.mvc.pojo.vo;

/**
 * 将服务端要响应到客户端的数据，统一封装到此类型的对象中。
 */
public class JsonResult {
    /**状态码*/
    private Integer code;
    /**响应消息(通常是对状态码的描述)*/
    private String message;
    /**服务端响应到客户端的数据，例如从数据库查询到的数据*/
    private Object data;

    public JsonResult() {
    }
    public JsonResult(Object data) {
        this.code=StatusCode.SUCCESS.getCode();
        this.message=StatusCode.SUCCESS.getMessage();
        this.data=data;
    }
    public JsonResult(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.message = statusCode.getMessage();
    }
    public JsonResult(int code,String message) {
        this.code = code;
        this.message = message;
    }
    public JsonResult(StatusCode statusCode, Object data) {
        this(statusCode);
        this.data = data;
    }
    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }
}
